var g = function (arr) {
    return function () {
        let current = arr.shift()
        arr.push(current)
        return current
    }
}

const generate  = (min = 1, max = 10, step = 1) => {
    var arr = []
    for(let i = min; i <= max; i+=step) {
        arr.push(i)
    }
    return g(arr)
}
var a1 = generate(2,7)
console.log(a1())
console.log(a1())
console.log(a1())
console.log(a1())
console.log(a1())
console.log(a1())
console.log(a1())
console.log(a1())
console.log(a1())